const TOGGLE_SIDEBAR = 'TOGGLE_SIDEBAR'
const SET_NOTIFICATION = 'SET_NOTIFICATION'
const GET_SIDEBAR = 'GET_SIDEBAR'
const SET_PASSOWROD = 'SET_PASSOWROD'
const state = {
  sidebar: {
    opened: true
  },
  isBell: false,
  isEditPassword: false,
  notification: false,
  notificationB: false
}

const getters = {
  sidebar: state => state.sidebar,
  isBell: state => state.isBell,
  notification: state => state.notification,
  isEditPassword: state => state.isEditPassword
}

const actions = {
  toggleSideBar({ commit }) {
    commit(TOGGLE_SIDEBAR)
  },
  togglePassword({ commit }, data) {
    commit(SET_PASSOWROD, data)
  },
  async getNotification({ commit }, data) {
    commit(GET_SIDEBAR, data)
  },
  toggleNotification({ commit }, data) {
    commit(SET_NOTIFICATION, data)
  }
}

const mutations = {
  [TOGGLE_SIDEBAR](state) {
    state.sidebar.opened = !state.sidebar.opened
  },
  [GET_SIDEBAR](state, data) {
    if (data.length > 0) {
      state.isBell = true
    } else {
      state.isBell = false
    }
  },
  [SET_PASSOWROD](state, data) {
    if (data) {
      state.isEditPassword = false
    } else {
      state.isEditPassword = !state.isEditPassword
    }
  },
  [SET_NOTIFICATION](state, data) {
    if (data) {
      state.notification = false
    } else {
      state.notification = !state.notification
    }
  }
}

export default {
  state,
  getters,
  actions,
  mutations
}
